<?php

/**
 * sfGuardUser form.
 *
 * @package    form
 * @subpackage sf_guard_user
 * @version    SVN: $Id: sfGuardUserForm.class.php 13001 2008-11-14 10:45:32Z noel $
 */
class partnerForm extends BasesfGuardUserForm
{
  protected
    $pkName = null;

  public function configure()
  {
    parent::configure();
   


    unset(
      $this['last_login'],
      $this['created_at'],
      $this['salt'],
      $this['algorithm'],   
      $this['is_active'],
      $this['is_super_admin'],
      $this['sf_guard_user_group_list'],
      $this['sf_guard_user_permission_list']
    );
    
    // $lang = array('ru','en');
    
     $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'country'              => new sfWidgetFormInputHidden(array(),array('value'=>'UA')),
      'is_partner'              => new sfWidgetFormInputHidden(array(),array('value'=>'1')),
      'gender'              => new sfWidgetFormInputHidden(array(),array('value'=>'m')),
      'nickname'        => new sfWidgetFormInput(array(),array('size'=>25)),
      'username'        => new sfWidgetFormInput(array(),array('size'=>25)),
      'password'        => new sfWidgetFormInputPassword(),
      'contact_face'    => new sfWidgetFormInput(array(),array('size'=>45)),
      'adres'           => new sfWidgetFormInput(array(),array('size'=>45)),     
      'phone'           => new sfWidgetFormInput(array(),array('size'=>25)),
      'mobile_phone'    => new sfWidgetFormInput(array(),array('size'=>25)),
      'email'    => new sfWidgetFormInput(array(),array('size'=>25)),
      'icq'    => new sfWidgetFormInput(array(),array('size'=>25)),
      'count_user'    => new sfWidgetFormInput(array(),array('size'=>25)),
      'bank_information' => new sfWidgetFormTextarea(array(),array('style'=>'width:300px')),
      'custom_file1' =>  new inputPartnerImageTag (  array (), array('mat_id'=>$this->object->getId(),'folder'=>'partner') ),
      'custom_file2' =>  new inputPartnerImageTag (  array (), array('mat_id'=>$this->object->getId(),'folder'=>'partner') ),
     ));
     
     
	
     	$this->validatorSchema ['custom_file1'] = new sfValidatorFile ( array ('required' => false,
		'path' => sfConfig::get ( 'sf_web_dir' ) . '/uploads/partner',
		'mime_types' => 'web_images', 'max_size' => 500000, // 360 kB
                'validated_file_class' => 'sfPartnerValidatedFile' ) );
     	$this->validatorSchema ['custom_file2'] = new sfValidatorFile ( array ('required' => false,
		'path' => sfConfig::get ( 'sf_web_dir' ) . '/uploads/partner',
		'mime_types' => 'web_images', 'max_size' => 500000, // 360 kB
                'validated_file_class' => 'sfPartnerValidatedFile' ) );
     	
     	$this->validatorSchema ['password'] = new sfValidatorString(array('required' => false));
     	
     	              
     
    //  $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.')));
     
    
	     $this->widgetSchema->setLabels(
    array(
      'username'  => 'Логин',
      'nickname'    => 'Название агенства',
      'avatar'   => 'Аватар',  
      'icq' => 'Номер ICQ',
      'skype' => 'Номер skype',
      'email'     => 'E-mail',
      'password'  => 'Пароль',
      'country' => 'Страна',
      'gender' => 'Пол',
      'birthday' => 'Дата рождения',
      'password2' => 'Повтор пароля',
      'contact_face'=> 'ФИО директора',
      'mobile_phone'=> 'Мобильный телефон',
      'phone'=> 'Телефон',
      'adres'=> 'Адрес агентства',
      'count_user'=>'Кол-во сотрудников',
      'bank_information'=>'Банковская информация',
      'custom_file1' => 'Лицензия (скан ЧП)',
      'custom_file2' => 'Копия паспорта (скан паспорта директора)'

    )
    ); 

        $custom_decorator = new sfWidgetFormSchemaFormatterDefList($this->getWidgetSchema());
        $this->getWidgetSchema()->addFormFormatter('deflist', $custom_decorator);
        $this->getWidgetSchema()->setFormFormatterName('deflist');
	    
	     $this->validatorSchema->setOption('allow_extra_fields', true);
	     $this->widgetSchema->setNameFormat('user[%s]');

	   
       
  }
}

class sfWidgetFormSchemaFormatterDefList extends sfWidgetFormSchemaFormatter {
    protected
      $rowFormat                 = '<div class="sf_admin_form_row">%label%%error%%field%%help%%hidden_fields%</div>',
      $helpFormat                = '<span class="help">%help%</span>',
      $errorRowFormat            = '<dt class="error">Errors:</dt><dd>%errors%</dd>',
      $errorListFormatInARow     = '<ul class="error_list">%errors%</ul>',
      $errorRowFormatInARow      = '<li>%error%</li>',
      $namedErrorRowFormatInARow = '<li>%name%: %error%</li>',
      $decoratorFormat           = '<dl id="formContainer">%content%</dl>';
}